using System;
using System.Collections;
using System.Data;

namespace FreeFlow.Administration
{
  /// <summary>
  /// Collection of variables and their values within a folder
  /// </summary>
  public sealed class FolderVariableCollection : DictionaryBase, IDictionary
  {
    internal FolderVariableCollection(IDataReader reader)
    {
      DataTable schema = reader.GetSchemaTable();
      for (int i = 0; i < schema.Rows.Count; i++)
      {
        DataRow row = schema.Rows[i];
        switch (row["ColumnName"].ToString().ToUpper())
        {
          case "EFOLDERNAME" : break;
          case "EFOLDERID" : break;
          case "ESUBJECT" : break;
          case "EORIGINATOR" : break;
          case "EPRIORITY" : break;
          case "ECREATIONTIME" : break;
          case "EUPDATED" : break;
          case "EDEADLINE" : break;
          case "ESTAGENAME"  : break;
          case "EPARENT" : break;
          case "EENTRYTIME" : break;
          case "EACTIONAME" : break;
          case "EFRAGMENTSTACK" : break;
          case "ECATEGORY" : break;
          case "EMAPNAME" : break;
          case "EACTIONTIME" : break;
          case "EACTIONUSER" : break;
          case "ESERVERNAME" : break;
          case "EACTIONCOUNT" : break;
          case "EARCHIVED" : break;
          case "EACTIONNAME" : break;
          default : ((IDictionary)this).Add(row["ColumnName"], reader[row["ColumnName"].ToString()]); break;
        }
      }
    }

    bool IDictionary.IsFixedSize
    {
      get
      {
        return true;
      }
    }

    bool IDictionary.IsReadOnly
    {
      get
      {
        return true;
      }
    }

    /// <summary>
    /// Gets the value of the variable with the specified name.
    /// </summary>
    public string this[string name]
    {
      get
      {
        return ((IDictionary)this)[name].ToString();
      }
    }
  }
}
